<?php
class CartController extends AdminAppController{
    function index()
    {
        $this->loadModel('Admin.Cart');
        $cart_list = $this->Cart->get();
        $this->set('cart_list', $cart_list);
    }
    
    function detail($cart_id = null)
    {
        if($cart_id == ""){
            $this->redirect(array("controller" => "cart", 
                                  "action" => "index")
                            );
            exit;
        }
        
        $this->loadModel('Admin.Cart');
        $this->loadModel('Admin.User');
        $cart = $this->Cart->get_cart_by_id($cart_id);
        $this->set('cart', $cart);
        
        $user_id = $cart['Cart']['user_id'];
        $user_info = $this->User->findById($user_id);
        $this->set('user_info', $user_info);

        
        $detail_cart = $this->Cart->get_detail_cart($cart_id);
        $this->set('detail_cart', $detail_cart);
    }
    
    function edit($cart_id = null)
    {
        if($cart_id == ""){
            $this->redirect(array("controller" => "cart", 
                                  "action" => "index")
                            );
            exit;
        }
        
        $this->loadModel('Admin.Cart');
        $this->loadModel('Admin.User');
        
        $detail_cart = $this->Cart->get_detail_cart($cart_id);
        $this->set('detail_cart', $detail_cart);
    }
}